//
//  WmcRecognitionTipView.swift
//  YPWatermarkCamera
//
//  Created by 周诗松 on 2022/10/26.
//

import UIKit
import SDWebImage

class WmcRecognitionTipView: WmcBaseView {
    // Internal

    override func makeUI() {
        backgroundColor = .white
        layer.cornerRadius = 8

        addSubview(titleLabel)
        addSubview(imgView)
        addSubview(sureBtn)

        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(24)
            make.left.right.equalToSuperview()
            make.height.equalTo(22)
        }

        imgView.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(titleLabel.snp.bottom).offset(24)
            make.height.equalTo(200)
        }

        sureBtn.snp.makeConstraints { make in
            make.top.equalTo(imgView.snp.bottom)
            make.left.right.bottom.equalTo(0)
        }
    }

    override func bindViewAction() {
        sureBtn.yp.addEvent { _ in
            YPApp.CurrentVC?.dismiss(animated: false)
        }
    }

    // Private

    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.text = "点击钢筋，手动补充"
        label.font = .systemFont(ofSize: 18, weight: .medium)
        label.textColor = .wmc_grayH2_323233
        label.textAlignment = .center
        return label
    }()

    private lazy var imgView: UIImageView = {
        let data = (NSDataAsset(name: "recognition_guide", bundle: .WmcBundle)?.data ?? Data()) as Data
        let animatedImage = SDAnimatedImage(data: data)
        let view = UIImageView(image: animatedImage)
        return view
    }()

    private lazy var sureBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setTitle("我知道了", for: .normal)
        btn.titleLabel?.font = .systemFont(ofSize: 18, weight: .semibold)
        btn.setTitleColor(.wmc_blue_5290FD, for: .normal)
        return btn
    }()
}
